package com.niodata.dp.core.security;

import com.niodata.dp.core.OwnerType;
import com.niodata.dp.core.resource.Resource;
import com.niodata.dp.core.resource.ResourceDetail;
import com.niodata.dp.core.service.SystemService;
import com.niodata.dp.core.usermgr.model.UserInfo;
import java.util.List;

public interface OperationAccessControl {

  /**
   * check if user has Privilege to do action specified by access type onto resource.
   *
   * @param resourceDetail resource detail info
   * @param userInfo user info
   * @param accessType access type
   * @throws AccessDeniedException access exception
   */
  void checkPermission(ResourceDetail resourceDetail,
        UserInfo userInfo, String accessType) throws AccessDeniedException;

  void checkPermission(Resource resource,
        UserInfo userInfo, String accessType) throws AccessDeniedException;

  void checkServicePermission(long userId, long groupId, SystemService service)
        throws AccessDeniedException;

  void checkServicePermission(long userId, SystemService service)
        throws AccessDeniedException;

  void checkServicePermission(long userId, OwnerType ownerType, long ownerId,
        SystemService service)
        throws AccessDeniedException;

  List<String> getUserServicePermissions(long userId);
}
